package com.asen.commons.exception;

import com.asen.commons.core.base.enums.ResultTypeEnum;
import com.asen.commons.core.base.ResultCode;
import org.apache.commons.lang3.StringUtils;

public class BaseException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private ResultTypeEnum type;
    private ResultCode code;
    private String detail;

    public BaseException() {
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String message, String detail) {
        super(message);
        this.detail = detail;
    }

    public BaseException(ResultTypeEnum type, String message) {
        super(message);
        this.type = type;
    }

    public BaseException(ResultTypeEnum type, String message, String detail) {
        super(message);
        this.type = type;
        this.detail = detail;
    }

    public BaseException(ResultTypeEnum type, String message, String detail, Throwable cause) {
        super(message, cause);
        this.type = type;
        this.detail = detail;
    }

    public BaseException(ResultCode code) {
        this((ResultCode)code, (String)null);
    }

    public BaseException(ResultCode code, String message) {
        this((ResultCode)code, message, (String)null);
    }

    public BaseException(ResultCode code, String message, String detail) {
        super(StringUtils.defaultString(message, code.getMessage()));
        this.code = code;
        this.detail = detail;
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(String message, String detail, Throwable cause) {
        super(message, cause);
        this.detail = detail;
    }

    public ResultTypeEnum getType() {
        return this.type;
    }

    public void setType(ResultTypeEnum type) {
        this.type = type;
    }

    public ResultCode getCode() {
        return this.code;
    }

    public void setCode(ResultCode code) {
        this.code = code;
    }

    public String getDetail() {
        return this.detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }
}
